@extends('admin/layout')

@section('content')
<body class="login-bg">
    
    <div class="login">
        <div class="message">x-admin2.0-管理登录</div>
        <div id="darkbannerwrap"></div>
        
        <form method="" class="layui-form" >
            <input name="username" placeholder="用户名"  type="text" lay-verify="" class="layui-input" >
            <hr class="hr15">
            <input name="password" lay-verify="" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
            <hr class="hr20" >
        </form>
        <!-- @if (count($errors) > 0)
            <div class="alert alert-danger">
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif -->
    </div>

<script type="text/javascript">
layui.use(['layer','form', 'layedit'], function(){
    var form = layui.form
    ,layer = layui.layer


    //自定义验证规则
    form.verify({
      title: function(value){
        if(value.length < 5){
          return '标题至少得5个字符啊';
        }
      }
      ,pass: [/(.+){6,12}$/, '密码必须6到12位']
      ,content: function(value){
        layedit.sync(editIndex);
      }
    });

    
    //监听提交
    form.on('submit(login)', function(data){
      myAjax(url+'/admin/login/login',data.field,'post','json',function(res){
        if(res.status===0){
          layer.alert(res.msg,function (){
            location.href=url+'/admin';
          })
        }
      },function (res, textStatus, errorThrown){
        layer.msg(res.responseText,function (){

        })
      })
      return false;
    });
});
</script>
</body>
@endsection